package cn.ztuo.bitrade.controller.accessServiceChange;

import cn.ztuo.bitrade.annotation.AccessLog;
import cn.ztuo.bitrade.constant.AdminModule;
import cn.ztuo.bitrade.constant.SysConstant;
import cn.ztuo.bitrade.controller.BaseController;
import cn.ztuo.bitrade.entity.AccessServiceCharge;
import cn.ztuo.bitrade.entity.Admin;
import cn.ztuo.bitrade.service.AccessServiceChargeService;
import cn.ztuo.bitrade.util.MessageResult;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.SessionAttribute;

/**
 * @author: Xiazt
 * @date: 2020-05-11 11:18
 */
@RestController
@RequestMapping("accessSerciceChange")
public class AccessServiceChangeController extends BaseController {

    @Autowired
    private AccessServiceChargeService accessServiceChargeService;

    @RequiresPermissions("accessServiceChange:page-query")
    @RequestMapping(value = "page-query")
    @AccessLog(module = AdminModule.ACCESSSERVICECHANGE, operation = "分页获取币借贷手续费信息")
    public MessageResult getByPage(@SessionAttribute(SysConstant.SESSION_ADMIN) Admin admin, AccessServiceCharge accessServiceCharge) {
        return success(accessServiceChargeService.getByPage(accessServiceCharge));
    }

    @RequiresPermissions("accessServiceChange:save")
    @RequestMapping(value = "save")
    @AccessLog(module = AdminModule.ACCESSSERVICECHANGE, operation = "添加或修改币借贷手续费")
    public MessageResult save(AccessServiceCharge accessServiceCharge) {
        accessServiceChargeService.saveOrUpdate(accessServiceCharge);
        return success();
    }

    @RequiresPermissions("accessServiceChange:delete")
    @RequestMapping(value = "delete")
    @AccessLog(module = AdminModule.ACCESSSERVICECHANGE, operation = "删除币借贷手续费")
    public MessageResult delete(Long id) {
        accessServiceChargeService.delete(id);
        return success();
    }

}
